package cn.tedu.m1;

import cn.tedu.m1.Producer;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class Main {
    @Autowired
    private Producer producer;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Bean
    public Queue helloworldQueue() {
        // 默认是持久队列，  true,false,false
        return new Queue("helloworld", false);
    }

    // spring扫描创建完所有的实例，完成所有的依赖注入后,
    // 自动执行 @PostConstruct 注解的方法
    @PostConstruct
    public void test() {
        producer.send();
    }
}
